package com.ankicoo.practice.coding;

import java.util.*;
import java.util.stream.Collectors;

/**
 * Description:
 *
 * @author : QCYANG
 * @date : 2021/8/4 15:31
 */
public class Stream {
     class kv {
        private String k ;
        private Integer v;

        public kv(String k, Integer v) {
            this.k = k;
            this.v = v;
        }

        public String getK() {
            return k;
        }

        public void setK(String k) {
            this.k = k;
        }

        public Integer getV() {
            return v;
        }

        public void setV(Integer v) {
            this.v = v;
        }
    }


    public void run() {
        List<kv> a = new ArrayList<>();
        a.sort(Comparator.comparing(kv::getV));
        a.add(new kv("1",1));
        a.add(new kv("2",2));
        List<kv> collect = a.stream()
                .sorted(Comparator.comparing(kv::getV))
                .collect(Collectors.toList());
        collect.forEach(item-> System.out.println(item.getV()));
    }
}
